<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link href="css/all.css" rel="stylesheet"  media="all" type="text/css" />
<title>成都</title>
</head>
<style>
  .menu li{
    padding: 6px 0px !important;
  }

</style>
<body>
<div class="head">
  <div class="main"><span class=""><img src="images/logo.jpg" width="150"/></span>
    <p class="clear"></p>
  </div>
</div>
<div class="menu">
  <div class="main">
    <ul class="center">
      <li><a href="index.html">网站首页</a></li>
      <li><a href="jieshao.html">关于成都</a></li>
      <li><a href="chihewanle.html">吃喝玩乐</a></li>
      <li><a href="tupian.html">旅游风光</a></li>
      <li><a href="zhuce.html">会员注册</a></li> 
      <li><a href="denglu.html">会员登录</a></li>
      <li><a href="tuijian.html">美食展示</a></li>
      <li><a href="liuyan.html">留言</a></li>
    </ul>
  </div>
</div>  
<div class="main"> <div class="inban"><img src="images/img.jpg" width="100%" /> </div>
  <div class="content">
    <div class="bar">
      <h2 align="center">——欢迎注册成为会员——</h2>
    </div>
    <div class="form">
      <form id="zhuce" class="zhuce inp" name="zhuce" method="post" action="denglu.html" >
      <div class="nam">
        <label>姓名</label>
        <div class="div">
          <input id="zczh" name="first_name" type="text" placeholder="请输入您的姓名" class="inp">
        </div>
      </div>
      <div class="nam">
        <label>密码</label>
        <div class="div">
          <input name="psw" id="zcmm" type="password" size="20" maxlength="8" class="inp">
        </div>
      </div>
      <div class="nam">
        <label>性别</label>
        <div class="div">
          <input type="radio" name="radio" id="nan" value="radio">
          <span>男</span>
          <input type="radio" name="radio" id="nv" value="radio">
          <span>女</span></div>
      </div>
      <div class="nam">
        <label>电子邮箱</label>
        <div class="div">
          <input type="text" name="email" id="email" size="30" class="inp">
        </div>
      </div>
      <div class="nam">
        <label style="vertical-align:top">备注</label>
        <div class="div">
          <textarea name="bei" cols="30" rows="10" class="inp"></textarea>
        </div>
      </div>
      <div class="nam" style="text-align:center">
        <input name="sleep" type="button"  onclick="zc(event)" value="立即注册">
      </div>
      </form>
    </div>
    <div class="clear"></div>
  </div>
</div>
<div class="end">
  <p>成都 </p>
</div>
</body>
</html>
<script>
  function zc(event){
    var zh=document.querySelector("#zczh")
    var mm=document.querySelector("#zcmm")
    var obj={}
    var a=0
    obj.name=zh.value,
    obj.password=mm.value
    event.preventDefault()
    var arr=JSON.parse(localStorage.getItem("arr"))||[]
    for(let i=0;i<arr.length;i++){
       if(arr[i].name==zh.value){
          a=1
       }
    }
    if(nan.checked==false&&nv.checked==false){
      alert("请选择性别")
      return 
    }
 if(zh.value==""||zcmm.value==""){
       alert("账号或密码不能为空")
       return 
   }else if(a==1){
      alert("用户名已经被注册了")
      return 
   }
   arr.push(obj)
localStorage.setItem("arr",JSON.stringify(arr))
   console.log(arr)
   alert("恭喜你注册成功")
location.href="./index.html"
  }
</script>
